<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateAkbusWorkflowNodeProgramTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('akbus_workflow_node_program', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('name')->nullable()->comment('流转名称');
            $table->unsignedBigInteger('node_id')->comment('节点ID');
            $table->unsignedBigInteger('next_node_id')->comment('下个节点ID');
            $table->json('condition')->nullable()->comment('条件');
            $table->string('result_name')->nullable()->comment('审批结果名称');
            $table->string('result_key')->nullable()->comment('审批结果标识');
            $table->tinyInteger('result_status')->nullable()->comment('审批结果状态值');

            $table->foreign('node_id')->references('id')->on('akbus_workflow_node')->onDelete('cascade');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('akbus_workflow_node_program');
    }
}
